package com.chisheng.caa.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.chisheng.caa.mapper.CollegeMapper;
import com.chisheng.caa.pojo.dto.CollegeDTO;
import com.chisheng.caa.pojo.entity.College;
import com.chisheng.caa.service.CollegeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class CollegeServiceImpl implements CollegeService {

    @Resource
    private CollegeMapper collegeMapper;

    @Override
    public List<CollegeDTO> getCollegeList() {
        return collegeMapper.selectList(null).stream().map(college -> {
            CollegeDTO dest = new CollegeDTO();
            BeanUtil.copyProperties(college, dest);
            return dest;
        }).collect(Collectors.toList());
    }

    @Override
    public List<String> getCollegeNameList() {
        return collegeMapper.selectList(null).stream().map(College::getCollegeName)
                .collect(Collectors.toList());
    }

}
